{extends 'base/site2.html'}
{block name="page_header"}{include file="common/header.html" inline}{/block}
{block name="page_nav"}{include file="common/slide-nav.html" inline}{/block}
{block name="page_styles"}
<link rel="stylesheet" type="text/css" href="/css/mediation/user/index.css" />
{/block}
{block name="page_scripts"}
    <script type="text/javascript" src="/js/mediation/user/index.min.js" init="mediation/user/index"></script>
{/block}
{block name="page_section"}
    <div class="sessionPage bg-fff">
        <div class="page-header">
          <div class="left">
            <span class="line"></span>
            <strong class="tit">用户管理</strong>
          </div>
          <div class="right">
            <a href="/user/add">
              <button type="button" class="btn btn-info textright">新增</button>
            </a>
          </div>
        </div>
        <form class="small-style" method="get" action="" role="validform" enctype="multipart/form-data">
          <div class="form_row">
            <input type="hidden" name="limit" class="showlimit" value="10">
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">调解部门:</label>
                <div class="col-sm-7">
                    <select class="form-control selectpicker"    title="请选择" name="mediationOrganId" id="mediationOrganId">
                        {foreach from=$mediationOrgan  item=info}
                            <option class="u144_input_option" {if !empty($query.mediationOrganId) &&  $info.id== $query.mediationOrganId}selected="selected"{/if} value="{$info.id}">{$info.name}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">用户名:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if $query.name}{$query.name}{/if}" name="name" id="name" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">坐席:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if $query.workerId}{$query.workerId}{/if}" name="workerId" id="name" placeholder="请输入~">
                </div>
            </div>
            <div class="form-group col-lg-3 ui-select">
                <label for="exampleInputName2"  class="col-sm-4 control-label">手机号码:</label>
                <div class="col-sm-7">
                    <input type="text" class="form-control noempty col-sm-4"  value="{if $query.mobile}{$query.mobile}{/if}" name="mobile" id="mobile" placeholder="请输入~">
                </div>
            </div>
          </div>
          <div class="form_row">
            <div class="form-group col-lg-4 ui-select">
                <div class="col-lg-4" >
                    <button class="btn btn-primary col-lg-8 shousuoBtn"><span class="nav-icon glyphicon glyphicon-search" aria-hidden="true" style="margin-right: 2px"></span>查询</button>
                </div>
                <div class="col-lg-4">
                    <a type="button" href="/user/index" class="btn btn-default col-lg-8" ><span class="nav-icon glyphicon glyphicon-refresh" aria-hidden="true" style="margin-right: 2px"></span>重置</a>
                </div>
            </div>
            <div class="ui-select"></div>
            <div class="ui-select"></div>
            <div class="ui-select"></div>
          </div>

        </form>
    <div style="width: 95%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    overflow-x: scroll;">
        <table class="table table-striped table-bordered table-hover text-nowrap">
            <thead>
                <tr>
                    <th scope="col">序号</th>
                    <th scope="col">用户名</th>
                    <th scope="col">调解部门</th>
                    <th scope="col">手机号</th>
                    <th scope="col">用户角色</th>
                    <th scope="col">数据权限</th>
                    <th scope="col">坐席</th>
                    <th scope="col">坐席2</th>
                    <th scope="col">状态</th>
                    <th scope="col" class="fix-ele">操作</th>
                </tr>
            </thead>
            <tbody>
                {if $list}
                    {foreach from=$list key=key item=item}
                        <tr>
                            <td>{$item['num']}</td>
                            <td>{$item['name']}</td>
                            <td>{$mediationOrgan[$item['mediationOrganId']]['name']}</td>
                            <td>{$item['mobile']}</td>
                            <td>{$roles[$item['role_id']]}</td>
                            <td>{if $item['dataType'] ==1}仅自己{elseif $item['dataType'] ==2}本部门{elseif $item['dataType'] ==3}全部{elseif $item['dataType'] ==4}自定义部门{/if}</td>

                            <td>{if $item['workerId']}{$item['workerId']}{/if}</td>
                            <td>{if $item['workerId2']}{$item['workerId2']}{/if}</td>
                            <td>{$statusArr[$item['status']]}</td>
                            <td class="fix-ele">
                                <a href="/user/edit?id={$item['id']}">管理</a>
                                <a href="javascript:;" class="resetPWD" data-id='{$item['id']}'>重置密码</a>
                                {if $item['status']==2}
                                    <a href="javascript:;">
                                        <a href="javascript:;"  data-toggle="modal" data-target=".delmodal" data-id="{$item['id']}" role-click="modalshow">删除</a>
                                    </a>
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                {/if}
            </tbody>
        </table>
    </div>
    <div class="clearfix pad-no text-nowrap" style="margin-top: 20px;">
        {include file="base/pagenav.html"  action="/user/index" pagenum=$curPageNum inline}
        <span style="float:right;margin-right: 10px">共 {$totalnum} 条</span>

    </div>
        <div class="modal fade delmodal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">确认删除这条数据？</h4>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-danger" role-click="del" data-url="/user/del" data-id="">删除</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<script type="text/javascript" src="/js/mediation/del/del.min.js" init="mediation/del/del"></script>

    <script>
        $('body')
            .on('click','.resetPWD', function(){
                var that=$(this);
                $.confirm({
                    title: '注意！',
                    content: '确认重置密码，重置后默认密码：PWD123456！',
                    confirmButton: '确定',
                    cancelButton: '取消',
                    confirm: function(){
                        $.ajax({
                            url:"/user/resetPWD",
                            method:"post",
                            data:{
                                id: that.attr('data-id'),
                            },
                            success:function(res){
                                if(res.code==200){
                                    toastr.success("操作成功");
                                }else{
                                    toastr.error(res.message);
                                }
                            },
                            error: function(err){
                                toastr.error('网络错误,请稍后重试');
                            }
                        })
                    },
                    cancel: function(){
                        // alert('Canceled!')
                    }
                });
            })
    </script>
{/block}
